"""
输入：[7,1,5,3,6,4]
输出：5
"""

"""prices = [2,4,1,2]
price_min = 100000
profit = 0
for p in prices:
    profit = max(profit, p - price_min)
    price_min = min(price_min, p)
print(profit)"""

prices = [2,4,1,2]
min_prices=100000
profit = 0
for i in prices:
    if i-min_prices>profit:
        profit=i-min_prices
    if i<min_prices:
        min_prices=i
print(profit)



